package Model.InboxMessages;

import java.sql.Date;
import DBAccess.DBAccess;
import Model.Notification;
import Model.User;


public class Message {

  private int messageID;

  private int fromID;

  private int toID;

  private String message;
  
  private Date messageTime;
    
  public Message(int messageID, int fromID, int toID, String message, Date messageTime){
	  this.messageID=messageID;
	  this.fromID=fromID;
	  this.toID=toID;
	  this.message=message;
	  this.messageTime=messageTime;
  }
  public SimpleMessage inboxDisplay()
  {
	SimpleMessage simpleMsg = new SimpleMessage(message,fromID,messageTime,messageID);  
	return simpleMsg;
  }
  public int getMesssageID() {
  return this.messageID;
  }
  
  public static void sendMessage(int fromID, int toID, String message){
	  System.out.println(fromID+"f"+toID);
	 // if(Blocked.isBlocked(toID, fromID)) 
		//  return;
	  DBAccess.insertMessage(fromID, toID, message);
	  Notification.newNotification(toID, Notification.messageNotificationMessage(fromID), fromID);
  }

  public int getFromID() {
  return this.fromID;
  }
  public String getFrom(){
	  return User.getName(fromID);
  }

  public int getToID() {
  return this.toID;
  }

  public String getMessage() {
  return this.message;
  }
  public Date getMessageTime(){
	  return this.messageTime;
  }

}